package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.Address;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class GxAddress extends Address {
    public GxAddress(Element element) throws IllegalArgumentException {
        if (element.getElementsByTagName("CityName").getLength() > 0 &&
            element.getElementsByTagName("CityName").item(0).getChildNodes().getLength() > 0) {
            this.setCityName(((Node) element.getElementsByTagName("CityName").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("CountryCode").getLength() > 0 &&
            element.getElementsByTagName("CountryCode").item(0).getChildNodes().getLength() > 0) {
            this.setCountryCode(((Node) element.getElementsByTagName("CountryCode").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("PostalCode").getLength() > 0 &&
            element.getElementsByTagName("PostalCode").item(0).getChildNodes().getLength() > 0) {
            this.setPostalCode(((Node) element.getElementsByTagName("PostalCode").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("ProvinceCode").getLength() > 0 &&
            element.getElementsByTagName("ProvinceCode").item(0).getChildNodes().getLength() > 0) {
            this.setProvinceCode(((Node) element.getElementsByTagName("ProvinceCode").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("ProvinceName").getLength() > 0 &&
            element.getElementsByTagName("ProvinceName").item(0).getChildNodes().getLength() > 0) {
            this.setProvinceName(((Node) element.getElementsByTagName("ProvinceName").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("StreetAddress").getLength() > 0 &&
            element.getElementsByTagName("StreetAddress").item(0).getChildNodes().getLength() > 0) {
            this.setStreetAddress(((Node) element.getElementsByTagName("StreetAddress").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("StreetAddress2").getLength() > 0 &&
            element.getElementsByTagName("StreetAddress2").item(0).getChildNodes().getLength() > 0) {
            this.setStreetAddress2(((Node) element.getElementsByTagName("StreetAddress2").item(0).getChildNodes().item(0)).getNodeValue());
        }
    }
}
